package com.zxy.broker.controller;

import java.util.Arrays;
import java.util.Map;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.zxy.broker.entity.HousingResourceEntity;
import com.zxy.broker.service.HousingResourceService;
import com.zxy.common.utils.PageUtils;
import com.zxy.common.utils.R;



/**
 * 
 *
 * @author axy
 * @email sunlightcs@gmail.com
 * @date 2022-04-27 18:48:51
 */
@RestController
@RequestMapping("broker/housingresource")
@CrossOrigin
public class HousingResourceController {
    @Autowired
    private HousingResourceService housingResourceService;

    /**
     * 列表
     */
    @RequestMapping("/list")

    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = housingResourceService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{zid}")

    public R info(@PathVariable("zid") Integer zid){
		HousingResourceEntity housingResource = housingResourceService.getById(zid);

        return R.ok().put("housingResource", housingResource);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")

    public R save(@RequestBody HousingResourceEntity housingResource){
		housingResourceService.save(housingResource);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody HousingResourceEntity housingResource){
		housingResourceService.updateById(housingResource);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] zids){
		housingResourceService.removeByIds(Arrays.asList(zids));

        return R.ok();
    }

}
